package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import com.sky.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    ShoppingCart getByShoppingCartDTO(ShoppingCartDTO shoppingCartDTO, Long userId);

    @Update("update shopping_cart set number=number+1 where id=#{id}")
    void updateAddOne(Long id);

    void insert(ShoppingCart shoppingCart);

    @Select("SELECT * FROM `shopping_cart` where user_id=#{userId}")
    List<ShoppingCart> getListByUserId(Long userId);

    @Delete("delete from shopping_cart where user_id=#{userId}")
    void deleteByUserId(Long userId);


    //统计购物车商品
}
